
*******************************************************************************
****						Appendix Table G.16 - REGRESSION OF TOTAL TOLL ****
****			ON TIME DIFFERENTIALS: SEGMENT ROBUSTNESS				*******
*******************************************************************************

use ".\data\clean\I10W_laneuse_dataset_15nov14_wcensus", clear

merge m:1 date hour using ".\data\clean\HV_ML_reliab.dta", keep(1 3) nogen 
gen reliabilityML=dist/p20_speedML-dist/p50_speedML
gen reliabilityHV=dist/p20_speedHV-dist/p50_speedHV
gen reliability_diff=reliabilityML-reliabilityHV
replace reliability_diff=0 if reliability_diff<0.01
keep if reliability_diff~=.
la var reliability_diff "Reliability"

*WTP calculation
gen TT_dif_hr=dist/MLspeed-dist/ELspeed
gen WTP2=charged_toll/TT_dif_hr
drop if ELspeed==.
drop if TT_dif_hr==.
drop if holiday==1
la var TT_dif_hr "Time in Hours"
drop if dow==0|dow==6
keep if acct_type=="PRIVATE"&occupancy~="HOV-3"
keep if hour>4 & hour<9
est sto clear
qui levelsof rt_id, l(rts)
foreach r of local rts{
	if "`r'"!="7"{
		reg charged_toll TT_dif_hr reliability_diff if TT_dif_hr>0 & rt_id==`r', cluster(month)
		est sto a`r'
		local alist "`alist' a`r'"
		}
	}
	

esttab `alist'  using ".\results\appendix\tabs\ATG16.csv", replace  ///
	cells(b(star fmt(%9.2f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(r2 N ,fmt(%9.2f %9.0f) ) label ///
	order(_cons TT_dif_hr reliability_diff) keep( TT_dif_hr reliability_diff _cons ) ///
	mtitle(`alist')  nonumbers nodepvars
	
insheet using ".\results\appendix\tabs\ATG16.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G.16", replace)
